from agent.qwen.api.DashScopeModel import DashScopeModel
from agent.qwen.api.OpenAiModel import OpenAiModel

class BaiLianApiService:
    def __init__(self, api_key="", base_url="", model="qwen-plus", api_type="openai", stream=False, thinking=False):
        if api_type == "openai":
            self.apiService = OpenAiModel(api_key=api_key,
                                          base_url=base_url,
                                          model=model,
                                          stream=stream,
                                          thinking=thinking)
        else:
            self.apiService = DashScopeModel(api_key=api_key,
                                             base_url=base_url,
                                             model=model,
                                             stream=stream,
                                             thinking=thinking)

    # 对话
    def chat(self, messages):
        return self.apiService.chat(messages)